		$(function(){
				$("#myoTable").datagrid({
				pagination:true,
				idField:"id"
			});
		})
		//根据name条件查询
		function setCondition(){
			
			var postData = {name : $("#name").val()};
			$("#myoTable").datagrid("reload",postData)
		}
		function resetCondition(){
			$("#userCondition").form("clear");
		}
		//添加
		function add_myo(){
			var d = $("<div></div>").appendTo("body");
			d.dialog({
				title:"添加器械",
				width:500,
				height:300,
				modal:true,
				href:"myo/myoAdd",
				onClose:function(){$(this).dialog("destroy");},
				buttons:[{
					text:"确定",
					handler:function(){
						$("#myoForm").form("submit",{
							url:"myo/add",
							success:function(data){
								d.dialog("close");
								$("#myoTable").datagrid("reload");
							}
						});
					}
				},{
					text:"取消",
					handler:function(){
						d.dialog("close");
					}
				}]
			});
		}
		//修改
		function edit_myo(){
			var row = $("#myoTable").datagrid("getSelected");
			if(row == null){
				return;
			}
			$("#myoTable").datagrid("clearSelections");
			$("#myoTable").datagrid("selectRecord",row.id);
			var d = $("<div></div>").appendTo("body");
			d.dialog({
				title:"编辑",
				width:500,
				height:300,
				modal:true,
				href:"myo/myoAdd",
				onClose:function(){$(this).dialog("destroy");},
				onLoad:function(){
					$.post("myo/view",{id:row.id},function(data){
						$("#myoForm").form("load",data);
						
					});
				},
				buttons:[{
					text:"确定",
					handler:function(){
						$("#myoForm").form("submit",{
							url:"myo/edit",
							success:function(data){
								d.dialog("close");
								$("#myoTable").datagrid("reload");
							}
						});
					}
				},{
					text:"取消",
					handler:function(){
						d.dialog("close");
					}
				}]
			});
		}
		function deleteMyo(){
			var selRows = $("#myoTable").datagrid("getSelections");
			if(selRows.length == 0){
				$.messager.alert("提示","请选中要删除的数据行！","warning");
				return;
			}
			$.messager.confirm("提示","确定要删除选中的数据吗？",function(r){
				if(r){
					//3. 发送异步请求，带选中行的编号
					//拼接删除条件
					var postData = "";
					$.each(selRows,function(i){
						postData += "ids="+this.id;
						if(i < selRows.length - 1){
							postData += "&";
						}
					});
				}
				$.post("myo/deleteMyo",postData,function(data){
					if(data.result == true){
						//4. 删除成功后，刷新表格 reload
						$("#myoTable").datagrid("reload");
					}
				});
			});
		}
